package com.happytoad.libs.riatrax
{	
	import mx.controls.RadioButtonGroup;
	import mx.events.ItemClickEvent;

	/**
	 *  The RadioButtonGroup component includes automatic Google Analytic tracking.
	 *
	 *  <br/><br/>
	 *  Copyright (c) 2009 HappyToad IT Consulting (<a href="http://www.happytoad.com" target="_blank">http://www.happytoad.com</a>)<br/>
     *  Created by Rich Tretola (<a href="http://blog.everythingflex.com" target="_blank">http://blog.everythingflex.com</a>)<br/>
	 *  
	 *  @mxml
	 *
	 *  <p>The <code>&lt;rx:RadioButtonGroup&gt;</code> tag inherits all of the
	 *  tag attributes of its superclass,  and adds the following tag attributes:</p>
	 *
	 *  <pre>
	 *  &lt;rx:RadioButtonGroup
	 *    <strong>Properties</strong>
	 *    gaCategory="any"
	 *    gaAction="any"
	 *    gaLabel="any"
	 *    gaValue="1"
	 *    gaMode="unique|all|none"
	 *    &gt;
	 *  </pre>
	 * 
	 *	@includeExample examples/RadioButtonGroupExample.mxml 
	 * 
	 * @see com.happytoad.libs.riatrax.Tracker
	 */
	
	public class RadioButtonGroup extends mx.controls.RadioButtonGroup
	{
		include "SharedInclude.as";
		/**
     	 *  Constructor.
     	 */
		public function RadioButtonGroup()
		{
			super();
			this.addEventListener(ItemClickEvent.ITEM_CLICK,clicked);
		}
		/**
	     *  @private
	     *  EventListener for ItemClickEvent.ITEM_CLICK
	     *  calls trackIt
	     *  if no gaCategory is supplied, className will be recorded
	     *  if no gaAction is supplied, event.type will be recorded
	     *  if no gaLabel is supplied, selectedValue will be recorded
	     */
		private function clicked(event:ItemClickEvent):void{
			var o:com.happytoad.libs.riatrax.RadioButtonGroup = event.target as com.happytoad.libs.riatrax.RadioButtonGroup;
			trackIt(gaCategory != null ? gaCategory : "RadioButtonGroup",
				    gaAction != null ? gaAction : event.type,
				    gaLabel != null ? gaLabel : event.currentTarget.selectedValue,
				    gaValue);
		}
	}
}